package net.flyinggroup.reactor.springdeveloper;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.event.EventListener;
import reactor.core.publisher.Flux;
import reactor.core.scheduler.Schedulers;
import reactor.tools.agent.ReactorDebugAgent;

@SpringBootApplication
public class ProductDebugAgent {
    public static void main(String[] args) {
        ReactorDebugAgent.init();
        ReactorDebugAgent.processExistingClasses();
        SpringApplication.run(ProductDebugAgent.class, args);
        Flux.range(0, 5)
                .single() // <-- Aha!
                .subscribeOn(Schedulers.parallel())
                .block();
    }

    @EventListener(ApplicationReadyEvent.class)
    public void go() {
        Flux.range(0, 5)
                .single() // <-- Aha!
                .subscribeOn(Schedulers.parallel())
                .block();
    }
}

